package com.headwind.logistics.system.service.impl;

import com.headwind.logistics.common.pojo.Message;
import com.headwind.logistics.system.mapper.MessageMapper;
import com.headwind.logistics.system.service.intl.MessageServiceIntl;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Author 桂祥宇
 * @Date 2020/7/24 0024 9:21
 * @Version 1.0
 * @DESCRIPTION 消息通知务逻辑层实现类
 */
@Service
public class MessageServiceImpl implements MessageServiceIntl {

    //访问消息通知数据访问层
    @Resource
    private MessageMapper messageMapper;



    /**
     * 查询所有消息通知
     * @param page 页码
     * @param rows 行数
     * @return
     */
    @Override
    public List<Message> queryAllMessage(@Param("page")Integer page, @Param("rows")Integer rows){
        if (page != null){
            page = (page-1)*rows;
        }
        return messageMapper.queryAllMessage(page,rows);
    }


    /**
     * 根据id删除消息通知
     * @param messgaeId 消息通知id
     * @return
     */
    @Override
    public int deleteMessage(int messgaeId){
        int count=messageMapper.deleteMessage(messgaeId);
        return count;
    }

    /**
     * 新增消息通知
     * @param message 消息通知对象
     * @return
     */
    @Override
    public int addMessage(Message message){
        int count =messageMapper.addMessage(message);
        return count;
    }

    /**
     * 修改消息通知
     * @param message 消息通知对象
     * @return
     */
    @Override
    public int updateMessage(Message message){
        int count =messageMapper.updateMessage(message);
        return count;
    }

    /**
     * 修改消息通知撤销时间
     * @param message 消息通知对象
     * @return
     */
    @Override
    public int updateMessageCancelTime(Message message){
        int count =messageMapper.updateMessageCancelTime(message);
        return count;
    }
}
